// StiFlossTable.h: interface for the CStiFlossTable class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_STIFLOSSTABLE_H__2DBC9CB2_D351_4F33_9A72_9C6F2E20F504__INCLUDED_)
#define AFX_STIFLOSSTABLE_H__2DBC9CB2_D351_4F33_9A72_9C6F2E20F504__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <afxtempl.h>

enum {FLOSS_1, FLOSS_2, FLOSS_3, FLOSS_4};

typedef struct _tagFLOSS 
{
	int lib_id;
	int index;
	BYTE symbol;

	COLORREF color;
} FLOSS;

class CStiFlossTable : public CObject  
{
public:
	CStiFlossTable();
	virtual ~CStiFlossTable();

	FLOSS* GetFloss(int id);
	POSITION Find(FLOSS* floss)
	{
		return m_Flosses.Find(floss);
	}
	FLOSS* Find(POSITION pos)
	{
		return m_Flosses.GetAt(pos);
	}
	void AddFloss(FLOSS* floss);
	void RemoveFloss(FLOSS* floss);
	void ChangeFloss(FLOSS* floss);
	void Clear()
	{
		POSITION pos = m_Flosses.GetHeadPosition();
		while (pos)
		{
			FLOSS* floss = m_Flosses.GetNext(pos);
			delete floss;
			floss = NULL;
		}
		m_Flosses.RemoveAll();
	}
	int GetCount()
	{
		return m_Flosses.GetCount();
	}

	CList<FLOSS*, FLOSS*>* GetFlossList()
	{
		return &m_Flosses;
	}
	void SetFlosses(CList<FLOSS*, FLOSS*>* pFlosses);
	BYTE GetIndex(POSITION pos)
	{
		BYTE i=1;
		POSITION posx = m_Flosses.GetHeadPosition();
		while (posx)
		{
			if (posx == pos)
			{
				return i;
			}
			FLOSS* floss = m_Flosses.GetNext(posx);
			i++;
		}
		return 0;
	}

	void DrawFlossTable(CDC* pDC, int sx, int sy, int line);
	virtual void Serialize(CArchive& ar);

protected:
	CList<FLOSS*, FLOSS*> m_Flosses;
};

#endif // !defined(AFX_STIFLOSSTABLE_H__2DBC9CB2_D351_4F33_9A72_9C6F2E20F504__INCLUDED_)
